<script type="text/javascript">var msgSubmitDraftConfirm ="<fmt:message key="ACTION_submitDraft.confirm"/>";</script>
<script type="text/javascript">var msgBankCreditApproveConfirm ="<fmt:message key="ACTION_bankCreditApprove.confirm"/>";</script>
<script type="text/javascript">var msgBankGotoCAConfirm ="<fmt:message key="ACTION_bankGotoCA.confirm"/>";</script>
<script type="text/javascript">var msgBankCreditDenyConfirm ="<fmt:message key="ACTION_bankCreditDeny.confirm"/>";</script>
<script type="text/javascript">var msgSubmitRequestConfirm ="<fmt:message key="ACTION_submitRequest.confirm"/>";</script>
<script type="text/javascript">var msgBondRequestApproveConfirm ="<fmt:message key="ACTION_bondRequestApprove.confirm"/>";</script>
<script type="text/javascript">var msgBondRequestDenyConfirm ="<fmt:message key="ACTION_bondRequestDeny.confirm"/>";</script>
<script type="text/javascript">var msgCcApproveConfirm ="<fmt:message key="ACTION_ccApprove.confirm"/>";</script>
<script type="text/javascript">var msgCaApproveConfirm ="<fmt:message key="ACTION_caApprove.confirm"/>";</script>
<script type="text/javascript">var msgCaBackDealerConfirm ="<fmt:message key="ACTION_caBackDealer.confirm"/>";</script>
<script type="text/javascript">var msgCaBackBankConfirm ="<fmt:message key="ACTION_caBackBank.confirm"/>";</script>
<script type="text/javascript">var msgScaApproveConfirm ="<fmt:message key="ACTION_scaApprove.confirm"/>";</script>
<script type="text/javascript">var msgScaBackConfirm ="<fmt:message key="ACTION_scaBack.confirm"/>";</script>
<script type="text/javascript">var msgBackValidation ="<fmt:message key="back_validation"/>";</script>
<script type="text/javascript">var msgQualificationApproveConfirm ="<fmt:message key="ACTION_qualificationApprove.confirm"/>";</script>
<script type="text/javascript">var msgQualificationBackConfirm ="<fmt:message key="ACTION_qualificationBack.confirm"/>";</script>
<script type="text/javascript">var msgApplyLoanConfirm ="<fmt:message key="ACTION_applyLoan.confirm"/>";</script>
<script type="text/javascript">var msgCancelLoanConfirm ="<fmt:message key="ACTION_cancelLoan.confirm"/>";</script>
<script type="text/javascript">var msgBondLoanApproveConfirm ="<fmt:message key="ACTION_bondLoanApprove.confirm"/>";</script>
<script type="text/javascript">var msgBondLoanDenyConfirm ="<fmt:message key="ACTION_bondLoanDeny.confirm"/>";</script>
<script type="text/javascript">var msgInsuranceLoanApproveConfirm ="<fmt:message key="ACTION_insuranceLoanApprove.confirm"/>";</script>
<script type="text/javascript">var msgInsuranceUploadCoverConfirm ="<fmt:message key="ACTION_insuranceUploadCover.confirm"/>";</script>
<script type="text/javascript">var msgInsuranceLoanBackConfirm ="<fmt:message key="ACTION_insuranceLoanBack.confirm"/>";</script>
<script type="text/javascript">var msgBankLoanApproveConfirm ="<fmt:message key="ACTION_bankLoanApprove.confirm"/>";</script>
<script type="text/javascript">var msgBankLoanBackConfirm ="<fmt:message key="ACTION_bankLoanBack.confirm"/>";</script>
<script type="text/javascript">var msgBankLoanedConfirm ="<fmt:message key="ACTION_bankLoaned.confirm"/>";</script>
<script type="text/javascript">var msgInsuranceConfirmPolicyConfirm ="<fmt:message key="ACTION_insuranceConfirmPolicy.confirm"/>";</script>
<script type="text/javascript">var msgInsuranceUploadPolicyConfirm ="<fmt:message key="ACTION_insuranceUploadPolicy.confirm"/>";
var msgBackValidation="<fmt:message key="back_validation"/>";
var msgDenyValidation="<fmt:message key="deny_validation"/>";
var msgBackValidation2="<fmt:message key="back_validation2"/>";
var msgBackValidation3="<fmt:message key="back_validation3"/>";

function checkBack(type){
    if (type=="sca"){
        if($("#singleAuditComment").val()!=""){
            return confirm(msgScaBackConfirm);
        } else {
            alert(msgBackValidation);
            return false;
        }
    } else if(type=="qualification"){
        if($("#singleAuditComment").val()!=""){
            return confirm(msgQualificationBackConfirm);
        } else {
            alert(msgBackValidation);
            return false;
        }
    } else if(type=="insurance"){
        if($("#singleAuditComment").val()!=""){
            return confirm(msgInsuranceLoanBackConfirm);
        } else {
            alert(msgBackValidation2);
            return false;
        }
    } else if(type=="bank"){
        if($("#singleAuditComment").val()!=""){
            return confirm(msgBankLoanBackConfirm);
        } else {
            alert(msgBackValidation);
            return false;
        }
    } else if(type=="bank_deny"){
        if($("#singleDealerComment").val()!=""){
            return confirm(msgBankCreditDenyConfirm);
        } else {
            alert(msgDenyValidation);
            return false;
        }
    } else if(type=="ca_dealer"){
        if($("#singleDealerComment").val()!=""){
            return confirm(msgCaBackDealerConfirm);
        } else {
            alert(msgBackValidation3);
            return false;
        }
    } else if(type=="ca_bank"){
        if($("#singleAuditComment").val()!="") {
            return confirm(msgCaBackBankConfirm);
        } else {
            alert(msgBackValidation);
            return false;
        }
    }
}</script>


<c:if test="${loanRequest.dealerUser.username==pageContext.request.remoteUser or loanRequest.auditUser.username==pageContext.request.remoteUser}">
    <c:set var="actionEnable" scope="page" value="true" />
</c:if>

<c:if test="${(loanRequest.phase=='qualification_audit' or loanRequest.phase=='insurance_loan_audit' or loanRequest.phase=='insurance_confirm_policy')
    and loanRequest.dealer.masterProvider.bondUser.username==pageContext.request.remoteUser}">
    <c:set var="actionEnable" scope="page" value="true" />
</c:if>

<div class="box box-primary box-solid">
    <div class="box-header">
        <h3 class="box-title"><fmt:message key="loanRequestDetail.actionTitle"/></h3>
    </div>
    <!-- /.box-header -->
    <div class="box-body">
        <div class="form-group">
            <security:authorize ifAnyGranted="ROLE_CC">
                <c:if test="${actionEnable and loanRequest.status == 'request_audit'}">
                <div class="form-group">
                    <label class="control-label"><fmt:message key="loanRequest.pbocComment"/></label>
                    <form:textarea path="pbocComment" id="pbocComment" rows="2" cssClass="form-control" />
                </div>
                <button type="submit" class="btn btn-primary margin" id="ccApprove" name="ccApprove"
                        onclick="return confirm(msgCcApproveConfirm)?true:false;">
                    <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_ccApprove"/>
                </button>
                <a class="btn btn-default margin" target="blank" href="/personList?reqId=${loanRequest.id}"><fmt:message
                        key="loanRequestDetail.action.exportPersonList"/></a>
                </c:if>
            </security:authorize>

            <security:authorize ifNotGranted="ROLE_CC,ROLE_CA,ROLE_SCA,ROLE_Booking">
            <c:if test="${!(loanRequest.phase == 'draft')}">
                <div class="form-group">
                    <label class="control-label"><fmt:message key="loanRequest.dealerComment"/></label>
                    <form:textarea path="dealerComment" id="dealerComment" rows="3" cssClass="form-control" readonly="true"/>
                </div>
            </c:if>
            </security:authorize>

            <security:authorize ifNotGranted="ROLE_DEALER_USER,ROLE_CC,ROLE_CA,ROLE_SCA,ROLE_Booking">
                <label class="control-label"><fmt:message key="loanRequest.auditComment"/></label>
                <form:textarea path="auditComment" id="auditComment" rows="3" cssClass="form-control" readonly="true"/>
            </security:authorize>

            <security:authorize ifAnyGranted="ROLE_CC,ROLE_CA,ROLE_SCA,ROLE_Booking">
                <div class="form-group">
                    <label class="control-label"><fmt:message key="loanRequest.dealerComment"/></label>
                    <form:textarea path="dealerComment" id="dealerComment" rows="3" cssClass="form-control" readonly="true"/>
                    <c:if test="${editCondition and pageContext.request.getParameter('mode')!='edit'}">
                        <form:textarea path="singleDealerComment" id="singleDealerComment" rows="2" cssClass="form-control" />
                    </c:if>
                </div>
                <label class="control-label"><fmt:message key="loanRequest.auditComment"/></label>
                <form:textarea path="auditComment" id="auditComment" rows="3" cssClass="form-control" readonly="true"/>
                <c:if test="${pageContext.request.getParameter('mode')!='edit'}">
                <div class="form-group">
                    <c:if test="${editCondition}">
                    <form:textarea path="singleAuditComment" id="singleAuditComment" rows="2" cssClass="form-control" />
                    </c:if>
                </div>
                </c:if>
            </security:authorize>
            <security:authorize ifNotGranted="ROLE_DEALER_USER,ROLE_CC,ROLE_Insurance,ROLE_Bank_USER,ROLE_Bond_USER">
                <c:if test="${!(loanRequest.phase=='draft' || loanRequest.phase=='dealer_submit' || loanRequest.phase=='bank_credit_audit') and pageContext.request.getParameter('mode')!='edit'}">
                <label class="margin"><form:radiobutton path="auditCode" value="approve" cssClass="insure" disabled="${!editCondition}"/><fmt:message key="loanRequest.approve"/></label>
                    <label class="margin"><form:radiobutton path="auditCode" value="changeApprove" cssClass="insure" disabled="${!editCondition}"/><fmt:message key="loanRequest.changeApprove"/></label>
                    <label class="margin"><form:radiobutton path="auditCode" value="deny" cssClass="insure" disabled="${!editCondition}"/><fmt:message key="loanRequest.deny"/></label>
                    <label class="margin"><form:radiobutton path="auditCode" value="cancel" cssClass="insure" disabled="${!editCondition}"/><fmt:message key="loanRequest.cancel"/></label>
                    <br/>
                </c:if>
            </security:authorize>

            <security:authorize ifAnyGranted="ROLE_DEALER_USER">
                <c:if test="${actionEnable}">
                <c:if test="${loanRequest.phase=='dealer_apply_loan'}">
                    <button type="submit" class="btn btn-primary margin" id="applyLoan" name="applyLoan" onclick="return confirm(msgApplyLoanConfirm);"
                            <c:if test="${not loanRequest.dealer.loanEnabled}">disabled</c:if>>
                        <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_applyLoan"/></button>
                    <button type="submit" class="btn btn-danger margin" id="cancelLoan" name="cancelLoan" onclick="return confirm(msgCancelLoanConfirm);"
                            <c:if test="${not loanRequest.dealer.loanEnabled}">disabled</c:if>>
                        <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_cancelLoan"/></button>
                </c:if>

                </c:if>
            </security:authorize>

            <security:authorize ifAnyGranted="ROLE_CA">
                <c:if test="${pageContext.request.getParameter('mode')=='edit'}">
                    <button type="submit" class="btn btn-primary margin" id="save" name="save">
                        <i class="icon-ok icon-white"></i> <fmt:message key="button.save"/></button>
                </c:if>
                <c:if test="${actionEnable and loanRequest.phase=='ca_audit' and pageContext.request.getParameter('mode')!='edit'}">
                    <button type="submit" class="btn btn-primary margin" id="caSaveAudit" name="caSaveAudit">
                        <i class="icon-ok icon-white"></i> <fmt:message key="button.save"/>
                    </button>
                    <button type="submit" class="btn btn-primary margin" id="caApprove" name="caApprove"
                            onclick="return confirm(msgCaApproveConfirm);">
                        <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_caApprove"/>
                    </button>
                    <button type="submit" class="btn btn-danger margin" id="caBackDealer" name="caBackDealer"
                            onclick="return checkBack('ca_dealer');">
                        <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_caBackDealer"/>
                    </button>
                    <button type="submit" class="btn btn-danger margin" id="caBackBank" name="caBackBank"
                            onclick="return checkBack('ca_bank');">
                        <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_caBackBank"/>
                    </button>
                    <a href="/export/businessForm?reqId=${loanRequest.id}" class="btn btn-warning margin" id="exportBusinessForm" >
                        <fmt:message key="ACTION_exportBusinessForm"/></a>
                    <a href="/export/insuranceForm?reqId=${loanRequest.id}" class="btn btn-warning margin" id="exportInsuranceForm" >
                        <fmt:message key="ACTION_exportInsuranceForm"/></a>
                    <a href="/export/auditResult?reqId=${loanRequest.id}" class="btn btn-warning margin" id="exportAuditResult" >
                        <fmt:message key="ACTION_exportAuditResult"/></a>
                </c:if>
            </security:authorize>

            <security:authorize ifAnyGranted="ROLE_SCA">
                <c:if test="${pageContext.request.getParameter('mode')=='edit'}">
                    <button type="submit" class="btn btn-primary margin" id="save" name="save">
                        <i class="icon-ok icon-white"></i> <fmt:message key="button.save"/></button>
                </c:if>
                <c:if test="${actionEnable and loanRequest.phase=='sca_audit' and pageContext.request.getParameter('mode')!='edit'}">
                    <button type="submit" class="btn btn-primary margin" id="scaSaveAudit" name="scaSaveAudit">
                        <i class="icon-ok icon-white"></i> <fmt:message key="button.save"/>
                    </button>
                    <button type="submit" class="btn btn-primary margin" id="scaApprove" name="scaApprove"
                            onclick="return confirm(msgScaApproveConfirm);">
                        <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_scaApprove"/>
                    </button>
                    <button type="submit" class="btn btn-danger margin" id="scaBack" name="scaBack"
                            onclick="return checkBack('sca');">
                        <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_scaBack"/>
                    </button>
                    <%--<a class="btn btn-primary margin" href="/backToCA?reqId=${loanRequest.id}"><fmt:message key="loanRequestDetail.action.back.ca"/></a>--%>
                </c:if>
            </security:authorize>

            <security:authorize ifAnyGranted="ROLE_Bond_USER">
                <c:if test="${actionEnable}">
                    <c:if test="${loanRequest.phase == 'bond_request_audit'}">
                        <button type="submit" class="btn btn-primary margin" id="bondRequestApprove" name="bondRequestApprove" onclick="return confirm(msgBondRequestApproveConfirm); ">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_bondRequestApprove"/></button>
                        <button type="submit" class="btn btn-danger margin" id="bondRequestDeny" name="bondRequestDeny" onclick="return confirm(msgBondRequestDenyConfirm); ">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_bondRequestDeny"/></button>
                    </c:if>
                    <c:if test="${loanRequest.phase == 'bond_loan_audit'}">
                        <button type="submit" class="btn btn-primary margin" id="bondLoanApprove" name="bondLoanApprove" onclick="return confirm(msgBondLoanApproveConfirm); ">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_bondLoanApprove"/></button>
                        <button type="submit" class="btn btn-danger margin" id="bondLoanDeny" name="bondLoanDeny" onclick="return confirm(msgBondLoanDenyConfirm); ">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_bondLoanDeny"/></button>
                    </c:if>
                </c:if>
            </security:authorize>

            <security:authorize ifAnyGranted="ROLE_Insurance,ROLE_Bank_USER">
                <c:if test="${loanRequest.phase == 'insurance_confirm_policy' or loanRequest.phase == 'insurance_upload_policy' or loanRequest.phase == 'bank_loan_audit'
                or loanRequest.phase == 'bank_pending_loan' or loanRequest.phase == 'loan_approved'}">
                    <div class="form-group">
                        </br>
                        <label class="control-label"><fmt:message key="loanRequest.loanDate"/></label>
                        <form:input path="loanDate" id="loanDate" cssClass="form-control" disabled="${!actionEnable or loanRequest.phase != 'bank_loan_audit'}"/>
                    </div>
                    <div class="form-group">
                        </br>
                        <label class="control-label"><fmt:message key="loanRequest.bankContractNo"/></label>
                        <form:input path="bankContractNo" id="bankContractNo" cssClass="form-control" disabled="${!actionEnable or loanRequest.phase != 'bank_loan_audit'}"/>
                    </div>
                    <br/>
                </c:if>
            </security:authorize>

            <!-- cover note number -->
            <security:authorize ifAnyGranted="ROLE_Insurance">
                <c:if test="${loanRequest.phase == 'insurance_upload_policy' and actionEnable}">
                    <div class="form-group">
                        <label class="control-label"><fmt:message key="loanRequest.coverNumber"/></label>
                        <form:input path="coverNumber" id="coverNumber" cssClass="form-control" />
                    </div>
                </c:if>
                <br/>
            </security:authorize>


            <!-- save and submit button -->
            <security:authorize ifAnyGranted="ROLE_DEALER_USER,ROLE_CC">
            <c:if test="${editCondition}">
                <button type="submit" class="btn btn-primary margin" id="save" name="save">
                    <i class="icon-ok icon-white"></i> <fmt:message key="button.save"/></button>
                <c:if test="${loanRequest.phase=='draft' and loanRequest.id != null}">
                    <button type="submit" class="btn btn-primary margin" id="submitDraft" name="submitDraft" onclick="return confirm(msgSubmitDraftConfirm)">
                        <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_submitDraft"/>
                    </button>
                </c:if>
                <c:if test="${loanRequest.phase=='dealer_submit' and loanRequest.id != null}">
                    <button type="submit" class="btn btn-primary margin" id="submitRequest" name="submitRequest" onclick="return confirm(msgSubmitRequestConfirm);">
                        <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_submitRequest"/>
                    </button>
                </c:if>
            </c:if>
            </security:authorize>

            <security:authorize ifAnyGranted="ROLE_Insurance">
                <c:if test="${actionEnable}">
                    <c:if test="${loanRequest.phase == 'qualification_audit'}">
                        <div class="form-group">
                            <label class="control-label"><fmt:message key="loanRequest.auditComment"/> <small><fmt:message key="approval.backComment"/></small></label>
                            <form:textarea path="singleAuditComment" id="singleAuditComment" rows="2" cssClass="form-control" />
                        </div>
                        <button type="submit" class="btn btn-primary margin" id="qualificationApprove" name="qualificationApprove" onclick="return confirm(msgQualificationApproveConfirm); ">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_qualificationApprove"/></button>
                        <button type="submit" class="btn btn-danger margin" id="qualificationBack" name="qualificationBack" onclick="return checkBack('qualification'); ">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_qualificationBack"/></button>
                    </c:if>
                    <c:if test="${loanRequest.phase == 'insurance_loan_audit'}">
                        <div class="form-group">
                            <label class="control-label"><fmt:message key="loanRequest.auditComment"/> <small><fmt:message key="approval.backComment"/></small></label>
                            <form:textarea path="singleAuditComment" id="singleAuditComment" rows="2" cssClass="form-control" />
                        </div>
                        <button type="submit" class="btn btn-primary margin" id="insuranceLoanApprove" name="insuranceLoanApprove" onclick="return confirm(msgInsuranceLoanApproveConfirm); ">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_insuranceLoanApprove"/></button>
                        <button type="submit" class="btn btn-danger margin" id="insuranceLoanBack" name="insuranceLoanBack" onclick="return checkBack('insurance');">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_insuranceLoanBack"/></button>
                    </c:if>
                    <%--<c:if test="${loanRequest.phase == 'insurance_upload_cover'}">
                        <button type="submit" class="btn btn-primary margin" id="insuranceUploadCover" name="insuranceUploadCover" onclick="return confirm(msgInsuranceUploadCoverConfirm); ">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_insuranceUploadCover"/></button>
                    </c:if>--%>
                    <c:if test="${loanRequest.phase == 'insurance_confirm_policy'}">
                        <button type="submit" class="btn btn-primary margin" id="insuranceConfirmPolicy" name="insuranceConfirmPolicy" onclick="return confirm(msgInsuranceConfirmPolicyConfirm); ">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_insuranceConfirmPolicy"/></button>
                    </c:if>
                    <c:if test="${loanRequest.phase == 'insurance_upload_policy'}">
                        <button type="submit" class="btn btn-primary margin" id="insuranceUploadPolicy" name="insuranceUploadPolicy" onclick="return confirm(msgInsuranceUploadPolicyConfirm); ">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_insuranceUploadPolicy"/></button>
                    </c:if>
                </c:if>
            </security:authorize>

            <security:authorize ifAnyGranted="ROLE_Bank_CREDIT">
                <c:if test="${loanRequest.phase == 'bank_credit_audit'}">
                    <div class="form-group">
                        <label class="control-label"><fmt:message key="loanRequest.dealerComment"/> <small><fmt:message key="approval.denyComment"/></small></label>
                        <form:textarea path="singleDealerComment" id="singleDealerComment" rows="2" cssClass="form-control" />
                    </div>
                    <button type="submit" class="btn btn-primary margin" id="save" name="save">
                        <i class="icon-ok icon-white"></i> <fmt:message key="button.save"/></button>
                    <button type="submit" class="btn btn-primary margin" id="bankCreditApprove" name="bankCreditApprove" onclick="return confirm(msgBankCreditApproveConfirm); ">
                        <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_bankCreditApprove"/></button>
                    <c:if test="${loanRequest.sendback}">
                        <button type="submit" class="btn btn-primary margin" id="bankGotoCA" name="bankGotoCA" onclick="return confirm(msgBankGotoCAConfirm); ">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_bankGotoCA"/></button>
                    </c:if>
                    <button type="submit" class="btn btn-danger margin" id="bankCreditDeny" name="bankCreditDeny" onclick="return checkBack('bank_deny'); ">
                        <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_bankCreditDeny"/></button>
                    <a class="btn btn-default margin" target="blank" href="/personList?reqId=${loanRequest.id}"><fmt:message
                            key="loanRequestDetail.action.exportPersonList"/></a>
                </c:if>
            </security:authorize>

            <security:authorize ifAnyGranted="ROLE_Bank_USER">
                <c:if test="${actionEnable}">
                    <c:if test="${loanRequest.phase == 'bank_loan_audit'}">
                        <div class="form-group">
                            <label class="control-label"><fmt:message key="loanRequest.auditComment"/> <small><fmt:message key="approval.backComment"/></small></label>
                            <form:textarea path="singleAuditComment" id="singleAuditComment" rows="2" cssClass="form-control" />
                        </div>
                        <button type="submit" class="btn btn-primary margin" id="bankLoanApprove" name="bankLoanApprove" onclick="return confirm(msgBankLoanApproveConfirm); ">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_bankLoanApprove"/></button>
                        <button type="submit" class="btn btn-danger margin" id="bankLoanBack" name="bankLoanBack" onclick="return checkBack('bank'); ">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_bankLoanBack"/></button>
                    </c:if>
                    <c:if test="${loanRequest.phase == 'bank_pending_loan'}">
                        <button type="submit" class="btn btn-primary margin" id="bankLoaned" name="bankLoaned" onclick="return confirm(msgBankLoanedConfirm); ">
                            <i class="icon-ok icon-white"></i> <fmt:message key="ACTION_bankLoaned"/></button>
                    </c:if>
                </c:if>
            </security:authorize>

            <security:authorize ifAnyGranted="ROLE_DEALER_USER">
                <c:if test="${loanRequest.phase != 'draft' and loanRequest.phase != 'dealer_submit' and loanRequest.phase != 'bank_credit_audit'}">
                    <a class="btn btn-default margin" href="/copyRequest?reqId=${loanRequest.id}" title='<fmt:message
                        key="loanRequest.copyHint" />'><fmt:message
                            key="loanRequestList.copy"/></a>
                </c:if>
                <c:if test="${loanRequest.id != null}">
                    <a class="btn btn-default margin" href="/attachments?reqId=${loanRequest.id}" ><fmt:message
                            key="loanRequestDetail.action.uploadFile"/></a>
                </c:if>
                <c:if test="${loanRequest.phase != 'draft' and loanRequest.phase != 'bank_credit_audit'}">
                    <a class="btn btn-success" href='/sendMaterials?reqId=${loanRequest.id}'><fmt:message key="button.material.send"></fmt:message></a>
                </c:if>
            </security:authorize>

            <security:authorize ifNotGranted="ROLE_DEALER_ADMIN,ROLE_DEALER_USER">
                <security:authorize ifAnyGranted="ROLE_Bank_CREDIT">
                    <c:if test="${loanRequest.phase == 'bank_credit_audit'}">
                        <c:set var="uploadEnable" scope="page" value="true" />
                    </c:if>
                </security:authorize>
                <security:authorize ifAnyGranted="ROLE_CA">
                    <c:if test="${loanRequest.phase == 'ca_audit'}">
                        <c:set var="uploadEnable" scope="page" value="true" />
                    </c:if>
                </security:authorize>
                <security:authorize ifAnyGranted="ROLE_M_RECEIVE">
                    <c:if test="${loanRequest.phase == 'pending_loan_material' or loanRequest.phase == 'bank_loan_audit'}">
                        <c:set var="uploadEnable" scope="page" value="true" />
                    </c:if>
                    <a class="btn btn-success" href='/receiveMaterials?reqId=${loanRequest.id}'><fmt:message key="button.material.receive"></fmt:message></a>
                </security:authorize>
                <security:authorize ifAnyGranted="ROLE_M_AUDIT">
                    <c:if test="${loanRequest.phase == 'dealer_apply_loan'}">
                        <c:set var="uploadEnable" scope="page" value="true" />
                    </c:if>
                    <a class="btn btn-success" href='/auditMaterials?reqId=${loanRequest.id}'><fmt:message key="button.material.audit"></fmt:message></a>
                </security:authorize>
                <security:authorize ifAnyGranted="ROLE_M_PRINT">
                    <c:if test="${loanRequest.phase == 'dealer_apply_loan' or loanRequest.phase == 'bank_loan_audit'}">
                        <c:set var="uploadEnable" scope="page" value="true" />
                    </c:if>
                    <a class="btn btn-success" href='/printMaterials?reqId=${loanRequest.id}'><fmt:message key="button.material.print"></fmt:message></a>
                </security:authorize>
                <security:authorize ifAnyGranted="ROLE_Insurance">
                    <c:if test="${loanRequest.phase == 'qualification_audit' or loanRequest.phase == 'insurance_upload_policy'}">
                        <c:set var="uploadEnable" scope="page" value="true" />
                    </c:if>
                </security:authorize>

                <c:if test="${!uploadEnable and pageContext.request.getParameter('mode')!='edit'}">
                <a class="btn btn-default margin" href="/attachments?reqId=${loanRequest.id}"><fmt:message key="loanRequestDetail.action.seeFile"/></a>
                </c:if>

                <c:if test="${uploadEnable}">
                <a class="btn btn-default margin" href="/attachments?reqId=${loanRequest.id}" ><fmt:message
                        key="loanRequestDetail.action.uploadFile"/></a>
                </c:if>
            </security:authorize>

            <security:authorize ifNotGranted="ROLE_DEALER_USER,ROLE_DEALER_ADMIN">
                <c:if test="${loanRequest.status != 'bank_credit_audit' and pageContext.request.getParameter('mode')!='edit'}">
            <a class="btn btn-default margin" id="open-creditInfo"><fmt:message key="loanRequest.credit.info"/></a>
                </c:if>
            </security:authorize>
            <%--<button type="submit" class="btn btn-default margin" id="cancel" name="cancel" onclick="bCancel=true">--%>
            <%--<i class="icon-remove"></i> <fmt:message key="button.cancel"/>--%>
            <%--</button>--%>
        </div>
    </div>

</div>

<%@include file="/WEB-INF/pages/loanrequestCreditInfo.jsp"%>